package com.msmall.community.play.cases.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.msmall.base.model.BaseObject;

/**
 * 游戏场景
 * @author zhzy
 *
 */
@Entity
@Table(name="play_cases_scenario")
public class Scenario extends BaseObject{

	private static final long serialVersionUID = 5883304178032247686L;

	@Id
	@Column(name="scenario_id")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long scenarioId;

	/**
	 * 编码 格式为 动作ID-对象ID。如果为 0-0表示开始。如果没有对象则 动作ID-0
	 */
	@Column(name="scenario_code")
	private String scenarioCode;
	
	/**
	 * 场景标题
	 */
	@Column(name="title")
	private String title;
	/**
	 * 场景内容
	 */
	@Lob
	@Column(name="content")
	private String content;
	
	/**
	 * 场景使用的图片路径
	 */
	@Column(name="image")
	private String image;
	
	/**
	 * 此场景的位置 1CASES开始 -1CASES结束,可以有多个结束，其他是一个CASES中间，参考ConstantDB
	 */
	@Column(name="position")
	private Integer position;
	
	/**
	 * 当position为结束-1时，判断是否是正确的结束；1正确的结束，-1错误的结束，参考ConstantDB
	 */
	private Integer answer;
	
	/**
	 * 1可用 0 不可用
	 */
	@Column(name="enabled")
	private Short enabled;
	
	@Column(name="create_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="cases_id")
	private Cases cases;
	
	@OneToMany(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE},fetch=FetchType.LAZY, mappedBy="scenario")
	private Set<Action> actions;
	
	@OneToMany(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE},fetch=FetchType.LAZY, mappedBy="scenario")
	private Set<Target> targets;
	
	public Long getScenarioId() {
		return scenarioId;
	}

	public void setScenarioId(Long scenarioId) {
		this.scenarioId = scenarioId;
	}

	public String getScenarioCode() {
		return scenarioCode;
	}

	public void setScenarioCode(String scenarioCode) {
		this.scenarioCode = scenarioCode;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public Integer getPosition() {
		return position;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}

	public Integer getAnswer() {
		return answer;
	}

	public void setAnswer(Integer answer) {
		this.answer = answer;
	}

	public Short getEnabled() {
		return enabled;
	}

	public void setEnabled(Short enabled) {
		this.enabled = enabled;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Set<Action> getActions() {
		return actions;
	}

	public void setActions(Set<Action> actions) {
		this.actions = actions;
	}

	public Set<Target> getTargets() {
		return targets;
	}

	public void setTargets(Set<Target> targets) {
		this.targets = targets;
	}

	public Cases getCases() {
		return cases;
	}

	public void setCases(Cases cases) {
		this.cases = cases;
	}

	@Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
}